package asa;

/**
 * 	SeStat ::= "se" Expr
                	StatList
            	[ "senão" ]
                	StatList
 * @author José
 *
 */

public class SeStat extends Statement {

	public SeStat(Expr expr, CompositeStatement seList, CompositeStatement senaoList) {
		this.expr = expr;
		this.seList = seList;
		this.senaoList = senaoList;
	}

	@Override
	public void genJava( PWInterface pw ) {
		genJava(pw, null);
	}

	@Override
    public void genJava( PWInterface pw, Env env ) {

        pw.printIdent("if ( ");
        expr.genJava(pw, false);
        pw.print(" ) ");
        if ( seList != null ) {
          seList.genJava(pw, env);
        }
        if ( senaoList != null ) {
          pw.printIdent("else ");
          senaoList.genJava(pw, env);
        }
    }

	private Expr expr;
	private CompositeStatement seList, senaoList;

}
